<template>

    <a-modal v-model:visible="LAYER.visible" :title="LAYER.title" :width="LAYER.width"
             :align-center="LAYER.alignCenter" :top="LAYER.top"
             :closable="LAYER.closable" :mask-closable="LAYER.maskClosable" :esc-to-close="LAYER.escToClose"
             :unmount-on-close="LAYER.unmountOnClose" :footer="LAYER.footer" :ok-text="LAYER.okText"
             :ok-loading="LAYER.okLoading" :cancel-text="LAYER.cancelText" :on-before-ok="onSubmit" @close="onCancel">

        <a-form ref="formRef" :model="formState" layout="vertical" :rules="RULES">
            <a-row :gutter="12">
                <a-col :span="24">
                    <a-form-item label="生成数量" field="count">
                        <a-input-number v-model="formState.count" allow-clear placeholder="请设置需要生成的虚拟会员数量"/>
                    </a-form-item>
                </a-col>
            </a-row>
        </a-form>
    </a-modal>

</template>
<script lang="ts" setup>

import {EditModal} from "@/libs/core";
import {GENERATED_EDIT} from '../resource/form'
import {SystemHttp} from '../resource/http'

const props = defineProps({record: {type: Object, required: true}})
const emit = defineEmits(['cancel'])


const {BODY, RULES} = GENERATED_EDIT
const config = {tplRecord: BODY, rawRecord: props.record, rowKey: 'id', emit}
// 将备注委托到封装类的执行方法上
const service = new EditModal(config).setAddRequest(SystemHttp.generatedMember);

const {formRef, formState, LAYER, onCancel, onSubmit} = service
service.isUpdate = false
service.LAYER.okText = "确定生成"

const title = `生成虚拟会员`
service.setMD(title, 500)
// eslint-disable-next-line vue/no-setup-props-destructure
formState.value.orderId = props.record.id
</script>

